From: Greg Sabino Mullane Date: Mon, 26 Mar 2007 01:13:39 +0000 (+0000) Subject: Find out the local db timezone X-Git-Tag: 1.31.0-rc.0~53607 X-Git-Url: http://git.cyclocoop.org/%22.%24info%5B?a=commitdiff_plain;h=72cb54091145c7a77a7d55aba7bface962e4c9ef;p=lhc%2Fweb%2Fwiklou.git Find out the local db timezone --- diff --git a/includes/DatabasePostgres.php b/includes/DatabasePostgres.php index bed25d8547..9e7d8c63b5 100644 --- a/includes/DatabasePostgres.php +++ b/includes/DatabasePostgres.php @@ -154,7 +154,7 @@ class DatabasePostgres extends Database { ## If this is the initial connection, setup the schema stuff and possibly create the user if (defined('MEDIAWIKI_INSTALL')) { global $wgDBname, $wgDBuser, $wgDBpassword, $wgDBsuperuser, $wgDBmwschema, - $wgDBts2schema; + $wgDBts2schema, $wgDBtimezone; print "
  • Checking the version of Postgres..."; $version = $this->getServerVersion(); @@ -165,6 +165,20 @@ class DatabasePostgres extends Database { } print "version $this->numeric_version is OK.
  • \n"; + print "
  • Figuring out timezone the database is using..."; + ## Figure out what the local timezone is for this database + $wgDBtimezone = 99; + if ($this->doQuery("SET datestyle TO ISO")) { + $res = $this->doQuery("SELECT substring(now() FROM E'-?\\\d\\\d\$')::int"); + if ($res) { + $wgDBtimezone = pg_fetch_result($res,0,0); + print "timezone is '$wgDBtimezone'
  • \n"; + } + } + if ($wgDBtimezone === 99) { + print "UNKNOWN. Defaulting to '0'\n"; + } + $safeuser = $this->quote_ident($wgDBuser); ## Are we connecting as a superuser for the first time? if ($wgDBsuperuser) {